package xw.qxypt.modules.baseinfo.controller;

import java.util.Arrays;
import java.util.Map;

import xw.qxypt.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import xw.qxypt.modules.baseinfo.entity.LhpWaysectGpsEntity;
import xw.qxypt.modules.baseinfo.service.LhpWaysectGpsService;
import xw.qxypt.common.utils.PageUtils;
import xw.qxypt.common.utils.R;



/**
 * 路段gps 表
 *
 * @author xw
 * @email 
 * @date 2019-11-28 16:38:08
 */
@RestController
@RequestMapping("baseinfo/lhpwaysectgps")
public class LhpWaysectGpsController {
    @Autowired
    private LhpWaysectGpsService lhpWaysectGpsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("baseinfo:lhpwaysectgps:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = lhpWaysectGpsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("baseinfo:lhpwaysectgps:info")
    public R info(@PathVariable("id") String id){
        LhpWaysectGpsEntity lhpWaysectGps = lhpWaysectGpsService.getById(id);

        return R.ok().put("lhpWaysectGps", lhpWaysectGps);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("baseinfo:lhpwaysectgps:save")
    public R save(@RequestBody LhpWaysectGpsEntity lhpWaysectGps){
        lhpWaysectGpsService.save(lhpWaysectGps);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("baseinfo:lhpwaysectgps:update")
    public R update(@RequestBody LhpWaysectGpsEntity lhpWaysectGps){
        ValidatorUtils.validateEntity(lhpWaysectGps);
        lhpWaysectGpsService.updateById(lhpWaysectGps);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("baseinfo:lhpwaysectgps:delete")
    public R delete(@RequestBody String[] ids){
        lhpWaysectGpsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
